<template>
    <div class='comment'>
        <div class='commentTop'>
            <span class='left'>用户评论</span>
            <span class='right' @click="commentPop">更多</span>
        </div>
        <div class='commentContent' v-for='(item,index) in comment' :key="index">
            <div class='commentUser'>
                <div><img :src='comment[index].headimg' @load="imgload"></div>
                <span>{{comment[index].name}}</span>
            </div>
        
            <div class='commentfoot'>
                <p>{{comment[index].comment}}</p>
                <span>{{Time(index)}}</span>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    data(){
        return{
        //    Time:'',
        }
    },
    methods:{
        imgload(){
            this.$emit('imgload')
        },
        commentPop(){
            this.$emit('commentPop')
        },
        Time(index){
         let date = new Date(this.comment[index].time)
         let Year = date.getFullYear();
         let Mounth = date.getMonth()+1;
         let Day = date.getDay();
         let Hourse = date.getHours()
         if(Hourse<10){
             Hourse='0'+Hourse
         }
         let Minutes =date.getMinutes();
         if(Minutes<10){
             Minutes = '0'+Minutes
         }
        return Year+'年'+Mounth+'月'+Day+'日'+'  '+Hourse+':'+Minutes;
        }
    },

        
    props:{
        comment:{
            type:Array,
            default(){
                return[]
            }
        }
    }
}
</script>

<style scoped>
    .comment{
        margin-top: 10px;
    }
    .commentContent{
        margin-top: 4px;
        clear: both;
        margin-bottom: 20px;
    }
    .commentfoot{
        clear: both;
    }
    .commentUser{
        height: 24px;
        margin-bottom: 10px;
        /* border: 1px solid red; */
    }
    .commentUser div img{
        width: 100%;
        vertical-align: middle;
    }
    .commentUser span{
        float: left;
    }
    .commentTop .left{
        float: left;
    }
    .commentTop .right{
        float: right;
    }
     .commentTop .left, .commentTop .right{
        width: auto;
    }
    .commentTop{
        height: 20px;
        border-top: 1px solid #000;
        border-bottom: 1px solid #000;
    }
    .commentUser div{
        width: 24px;
        height: 24px;
        border-radius: 50%;
        overflow: hidden;
        float: left;
        margin-right: 10px;
    }
    .commentfoot p{
        margin: 0 0 8px 0;
        padding: 0;
        
    }
    .commentfoot span{
        font-size: 12px;
    }
</style>